$(() => {
    const token = GetQueryString("token");
    const area_id = GetQueryString("area_id");
    const recommend_position = GetQueryString("recommend_position");
    let page = 1;
    let pageSize = 10;
    moreBrand(page);

    function moreBrand(page) {
        $.ajax({
            type: "post",
            url: url,
            data: { 'method': 'Goods|goods_list', 'area_id': area_id, 'recommend_position': recommend_position, 'p': page, 'page_size': pageSize },
            dataType: 'json',
            success: function(res) {
                if (res.status == 1) {
                    let data = res.data;
                    let html = '';
                    $('.hetitle').html(data.title);
                    data.list.forEach(item => {
                        html += `
                        <li class="iz2item">
                            <a href="comp_shopDetail.html?id=${item.id}&token=${token}" class="iz2link">
                                <img class="iz2pic" src="${item.goods_thumb}" alt="${item.goods_name}">`
                        html += `<span class="iz2title">
                                <p class="iz2ti1">${item.description}</p>`
                        if (item.price_show_model == 1) {
                            html += `<p class="iz2ti2">¥${item.goods_price}</p>`
                        } else if (item.price_show_model == 2) {
                            html += `<p class="iz2ti2"><del style="color:#666;font-size:.24rem;">¥${item.price_before}</del>/<span style="font-size:.28rem;">¥${item.goods_price}</span></p>`
                        } else {
                            html += `<p class="iz2ti2">¥${item.price_area}</p>`
                        }
                        html += `</span>
                            </a>
                        </li>
                        `;
                    })
                    if (data.list.length < pageSize) {
                        $('.notMore').css('display', 'flex');
                    }
                    $('.cloneLists').append(html);
                }
            }
        })
    }


    // 下拉加载更多
    $(window).scroll(function() {
        if ($(document).scrollTop() >= $(document).height() - $(window).height() - 1) {
            // console.log('我到底了');
            if ($('.notMore').css('display') != "flex") {
                page++;
                moreBrand(page);
            }
        }
    })
})